package database.singleDB;

import database.inter.ICommandExec;
import database.inter.ICommandPreRead;
import database.inter.ICommandPreWrite;
import database.inter.ICommandUndo;

import java.util.HashMap;

public class Command {
    public static HashMap<String, ICommandExec> cmdExecTable = new HashMap<>();
    public static HashMap<String, ICommandPreRead> cmdPreReadTable = new HashMap<>();
    public static HashMap<String, ICommandPreWrite> cmdPreWriteTable = new HashMap<>();
    public static HashMap<String, ICommandUndo> cmdUndoTable = new HashMap<>();

    public static void registerCommand(String cmdName, ICommandExec exec, ICommandPreRead preRead, ICommandPreWrite preWrite, ICommandUndo undo) {
        String lowerCaseCmd = cmdName.toLowerCase();
        cmdExecTable.put(lowerCaseCmd, exec);
        cmdPreReadTable.put(lowerCaseCmd, preRead);
        cmdPreWriteTable.put(lowerCaseCmd, preWrite);
        cmdUndoTable.put(lowerCaseCmd, undo);
    }

    public static String[] getFirstKey(String[] cmdLine) {
        return new String[]{cmdLine[1]};
    }

}
